import Heading from '@components/atoms/headings/heading'; import ResponsiveImage from '@components/molecules/images/responsive-image'; import PostsList from '@components/organisms/layout/posts-list'; import LinksListWidget from '@components/organisms/widgets/links-list-widget'; import { getLayout } from '@components/templates/layout/layout'; import PageLayout, { type PageLayoutProps, } from '@components/templates/page/page-layout'; import { getAllTopicsSlugs, getTopicBySlug, getTopicsPreview, getTotalTopics, } from '@services/graphql/topics'; import styles from '@styles/pages/topic.module.scss'; import { type NextPageWithLayout, type PageLink, type Topic, } from '@ts/types/app'; import { loadTranslation, type Messages } from '@utils/helpers/i18n'; import { getLinksListItems, getPageLinkFromRawData, getPostsWithUrl, } from '@utils/helpers/pages'; import { getSchemaJson, getSinglePageSchema, getWebPageSchema, } from '@utils/helpers/schema-org'; import useBreadcrumb from '@utils/hooks/use-breadcrumb'; import useSettings from '@utils/hooks/use-settings'; import { GetStaticPaths, GetStaticProps } from 'next'; import Head from 'next/head'; import { useRouter } from 'next/router'; import Script from 'next/script'; import { ParsedUrlQuery } from 'querystring'; import { useIntl } from 'react-intl'; export type TopicPageProps = { currentTopic: Topic; topics: PageLink[]; translation: Messages; }; const TopicPage: NextPageWithLayout = ({ currentTopic, topics, }) => { const { content, intro, meta, slug, title } = currentTopic; const { articles, cover, dates, seo, thematics, website: officialWebsite, } = meta; const intl = useIntl(); const { items: breadcrumbItems, schema: breadcrumbSchema } = useBreadcrumb({ title, url: `/sujet/${slug}`, }); const headerMeta: PageLayoutProps['headerMeta'] = { publication: { date: dates.publication }, update: dates.update ? { date: dates.update } : undefined, website: officialWebsite, total: articles ? articles.length : undefined, }; const { website } = useSettings(); const { asPath } = useRouter(); const webpageSchema = getWebPageSchema({ description: seo.description, locale: website.locales.default, slug: asPath, title: seo.title, updateDate: dates.update, }); const articleSchema = getSinglePageSchema({ cover: cover?.src, dates, description: intro, id: 'topic', kind: 'page', locale: website.locales.default, slug: asPath, title, }); const schemaJsonLd = getSchemaJson([webpageSchema, articleSchema]); const topicsListTitle = intl.formatMessage({ defaultMessage: 'Other topics', description: 'TopicPage: other topics list widget title', id: 'JpC3JH', }); const thematicsListTitle = intl.formatMessage({ defaultMessage: 'Related thematics', description: 'TopicPage: related thematics list widget title', id: '/sRqPT', }); const getPageHeading = () => { return ( <> {cover && } {title} ); }; return ( <> {seo.title}